package com.tanhua.domain.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Collections;
import java.util.List;

@Data
@NoArgsConstructor
public class PageResult implements Serializable {
    //总记录数
    private Integer counts = 0;
    //页大小
    private Integer pageSize;
    //页总数
    private Integer pages = 0;
    //当前页码
    private Integer page;
    //列表
    private List<?> items = Collections.EMPTY_LIST;

    public PageResult(Integer page, Integer pageSize, int counts, List<?> items) {
        this.counts = counts;
        this.pageSize = pageSize;
        this.pages = counts % pageSize == 0 ? counts / pageSize : counts / pageSize + 1;
        this.page = page;
        this.items = items;
    }
}
